﻿using System;

namespace Alabra.ExtensionMethods
{
    /// <summary>
    /// Contiene extensiones para DateTime
    /// </summary>
    public static class DateTimeExtension
    {
        /// <summary>
        /// Obtiene el primer día del mes
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static DateTime FirstDayOfMonth(this DateTime dateTime)
        {
            return dateTime.AddDays((-1 * dateTime.Day) + 1);
        }
        /// <summary>
        /// Retorna la fecha con el último día del mes
        /// </summary>
        /// <param name="dateTime"></param>
        /// <returns></returns>
        public static DateTime LastDayOfMonth(this DateTime dateTime)
        {
            return dateTime.AddDays(dateTime.AddMonths(1).FirstDayOfMonth().Subtract(dateTime).Days - 1);
        }
    }
}
